package com.copote.vmp.basedata.feign;

import com.copote.vmp.basedata.feign.factory.BasedataAPIFallbackFactory;
import com.copote.vmp.basedata.model.Result;
import com.copote.vmp.basedata.model.entity.VehicleInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@Component
@FeignClient(
        contextId = "BasedataAPI", // 如果同一服务拆分成很多接口，必须指定不同的contextId
        value = "microservice-basedata", // 这是服务名，必须和application.yaml中定义的服务名一样
//        url = "http://localhost:6701/", // url 是直连方式的微服务调用；如果是通过注册中心，必须注释该行。
        fallbackFactory = BasedataAPIFallbackFactory.class
)
public interface BasedataAPI {

    @GetMapping("/basedata/vehicle/getVehicleInfo")
    Result<VehicleInfo> getVehicleInfo(@RequestParam String id);

    @PostMapping("/basedata/vehicle/saveVehicleInfo")
    Result<?> saveVehicleInfo(@RequestBody VehicleInfo vehicleInfo);
}
